home *** CD-ROM | disk | FTP | other *** search
- unit RegContextMenu;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ComObj;
-
- type
- TRegContextMenu = class(TComponent)
- private
- { Private declarations }
- fGUID: String;
- fDesc: String;
- fPathName: String;
- fFileType: String;
- protected
- { Protected declarations }
- public
- { Public declarations }
- procedure Write;
- published
- { Published declarations }
- property GUID: String read fGUID write fGUID;
- property Description: String read fDesc write fDesc;
- property PathName: String read fPathName write fPathName;
- property FileType: String read fFileType write fFileType;
- end;
-
- procedure Register;
-
- implementation
-
- resourcestring
- sBadGUID = 'GUID string not set';
- sBadDesc = 'Description string not set';
- sBadPath = 'Pathname string not set';
- sBadFileType = 'FileType string not set';
-
- procedure TRegContextMenu.Write;
- begin
- { Make sure everything has been set }
- if fGUID = '' then raise Exception.Create (sBadGUID);
- if fDesc = '' then raise Exception.Create (sBadDesc);
- if fPathName = '' then raise Exception.Create (sBadPath);
- if fFileType = '' then raise Exception.Create (sBadFileType);
-
- { CreateRegKey will raise EOleError on failure }
- CreateRegKey ('CLSID\' + fGUID, '', Description);
- CreateRegKey ('CLSID\' + fGUID + '\InProcServer32', '', fPathName);
- CreateRegKey ('CLSID\' + fGUID + '\InProcServer32', 'ThreadingModel', 'Apartment');
- CreateRegKey (fFileType + '\shellex\ContextMenuHandlers\' + fGUID, '', '');
- end;
-
- procedure Register;
- begin
- RegisterComponents ('COM', [TRegContextMenu]);
- end;
-
- end.
-